package demo3_thread;

public class Main {
    public static void main(String[] args) {
        //使用匿名类定义thread类
        Thread thread=new Thread(){
            @Override
            public void run() {
                while(true){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("匿名类中的run方法正在执行");
                }
            }
        };
        //启动线程
        thread.start();
        while(true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Main方法正在执行");
        }
    }
}
